package com.analyze.analyzeFileText.image;

import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

import java.io.File;

/**
 * @ClassName OCRExample
 * @Description TODO
 * @Author Dell
 * @Date 2024/12/27
 **/


public class OCRExample {
    public static void main(String[] args) {
        Tesseract tesseract = new Tesseract();
        tesseract.setDatapath("path/to/tessdata"); // Tesseract的语言数据文件路径
        tesseract.setLanguage("chi_sim"); // 设置为简体中文

        try {
            String result = tesseract.doOCR(new File("image_path"));
            if (result.contains("装饰")) {
                System.out.println("图片中包含不允许的字样 '装饰'。");
            } else {
                System.out.println("图片通过审核。");
            }
        } catch (TesseractException e) {
            e.printStackTrace();
        }
    }
}

